var encoding = require('encoding')
var xdb = require('xdb')

function main() {
  xdb.new('zcx', `/database/zcx`)
  const document = JSON.parse(encoding.from(payload.body))
  let result = true
  try {
    Object.keys(document).forEach((item) => {
      xdb.setDocumentByID('zcx', 'role', document.id, item, document[item])
    })
  } catch (e) {
    result = false
  }

  return result
}
